﻿<UserControl x:Class="FIFP.DashBoard.Views.LSDManagement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"    
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    xmlns:local="clr-namespace:FIFP.DashBoard.Views"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    DataContext="{Binding ShutdownMngVM,Source={StaticResource ServiceLocator}}"
    d:DesignHeight="1028" d:DesignWidth="1920">

    <Grid x:Name="LayoutRoot" Margin="0,5,0,0">

        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.14*"/>
            <ColumnDefinition Width="0.11*"/>
            <ColumnDefinition Width="0.14*"/>
            <ColumnDefinition Width="0.18*"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="0.33*"/>
        </Grid.ColumnDefinitions>

       <!-- <ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Style="{StaticResource ScrollViewerStyle1}" Margin="0,12,10,0">-->
            <Grid Margin="0,35,10,0">
            <local:UCOptimizationFilter x:Name="ucFilter"></local:UCOptimizationFilter>
            </Grid>
       <!-- </ScrollViewer>-->

        <Grid Grid.Column="1" Margin="0,35,10,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="0">
                <Border BorderThickness="0" Margin="0,0,0,5" Background="#FF656565" BorderBrush="#99E9EEF4">
                    <TextBlock Margin="10,3,0,3" Text="Unit/Facility Search" HorizontalAlignment="Left"  Style="{StaticResource ContentHeading}"></TextBlock>
                </Border>
                <TextBox Name="txtSearch" Text="{Binding UnitName, Mode=TwoWay, ValidatesOnNotifyDataErrors=True,NotifyOnValidationError=True, UpdateSourceTrigger=Default}" MaxLength="100" Style="{StaticResource TextBoxStyle1}" TextWrapping="Wrap">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="KeyDown">
                            <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=ShutdownMngVM.UnitNameSearchCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                        </i:EventTrigger>
                        <i:EventTrigger  EventName="Loaded">
                            <i:InvokeCommandAction  Command="{Binding TextBoxLoadCommand}" CommandParameter="{Binding ElementName=txtSearch}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </TextBox>
            </StackPanel>

            <Grid x:Name="treeViewGrid" Grid.Row="1" Margin="0">
                <i:Interaction.Triggers>
                    <i:EventTrigger  EventName="Loaded">
                        <i:InvokeCommandAction Command="{Binding TreeviewGridLoaded}" 
        							CommandParameter="{Binding ElementName=treeViewGrid}"  />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </Grid>
            <!--<sdk:TreeView Name="treeView" Grid.Row="1" ItemsSource="{Binding TreeViewUnitList}" Margin="0,10,0,0" VerticalAlignment="Top" Style="{StaticResource TreeViewStyleSMUR}">
                <sdk:TreeView.ItemTemplate>
                    <sdk:HierarchicalDataTemplate ItemsSource="{Binding TowerUnitList}">
                        <StackPanel>
                            <TextBlock Text="{Binding UnitName}" Foreground="{Binding UnitNameTextColor}" IsHitTestVisible="{Binding IsNodeEnabled}"></TextBlock>
                        </StackPanel>
                    </sdk:HierarchicalDataTemplate>
                </sdk:TreeView.ItemTemplate>
                <i:Interaction.Triggers>
                    <i:EventTrigger  EventName="SelectedItemChanged">
                        <i:InvokeCommandAction Command="{Binding TreeviewSelectionChanged}" 
        							CommandParameter="{Binding ElementName=treeView}"  />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </sdk:TreeView>-->
        </Grid>

        <Grid Grid.Column="2" Margin="0,12,10,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Border BorderThickness="0" Margin="0,0,0,0" Grid.Row="0">
                <TextBlock Text="Linked Shutdown Locations" HorizontalAlignment="Left" Margin="0" Style="{StaticResource ContentHeading}"></TextBlock>
            </Border>

            <Grid x:Name="activitiesLocationGrid" Grid.Row="1" Margin="0">
                <sdk:DataGrid x:Name="linkedLocationGrid" Grid.Row="1" ItemsSource="{Binding FilteredLSDLocations}" AutoGenerateColumns="False" IsReadOnly="True"
                             Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" 
                                  ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" 
                                  CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding LSDLocationSelectionChanged}" 
        							CommandParameter="{Binding ElementName=linkedLocationGrid}" />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Type" Width="*" Binding="{Binding UnitType}" MinWidth="75"  />
                        <sdk:DataGridTextColumn Header="Name" Width="*" Binding="{Binding UnitName}" MinWidth="85"  />
                    </sdk:DataGrid.Columns>
                </sdk:DataGrid>
            </Grid>
        </Grid>
        <Grid Grid.Column="3" Margin="0,12,10,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Border BorderThickness="0" Margin="0,0,50,0" Grid.Row="0">
                <TextBlock Text="Activities with Linked Shutdown" HorizontalAlignment="Left" Style="{StaticResource ContentHeading}"></TextBlock>
            </Border>

            <Grid x:Name="activitiesGrid" Grid.Row="1" Margin="0">
                <sdk:DataGrid x:Name="activitiesOnSelectedUnitGrid" ItemsSource="{Binding FilteredActivityListWithSelectedUnit}" AutoGenerateColumns="False" 
                          Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" IsReadOnly="True" HorizontalAlignment="Stretch">
                    <i:Interaction.Triggers>
                        <i:EventTrigger  EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding ActivitySelectChanged}" 
        							CommandParameter="{Binding ElementName=activitiesOnSelectedUnitGrid}"  />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>

                    <sdk:DataGrid.Columns>                        
                        <sdk:DataGridTextColumn Header="Activity" Width="*" Binding="{Binding ActivityCode, Mode=OneWay}" MinWidth="75" />
                        <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=dd/MM/yyyy}" Width="110" />
                        <sdk:DataGridTextColumn Header="End Date" Binding="{Binding End,   Mode=OneWay, StringFormat=dd/MM/yyyy}" Width="110" />
                    </sdk:DataGrid.Columns>

                </sdk:DataGrid>
            </Grid>

        </Grid>
        <StackPanel Grid.Column="4" Margin="0,35,10,0" Width="190">

            <Button x:Name="btnSIMOPS" IsEnabled="{Binding IsApplySIMOPSEnabled}" Content="Apply SIMOPS" Style="{StaticResource OverlapButtonStyle}" Margin="0,0,0,10" Cursor="Hand">
        		<i:Interaction.Triggers>
        			<i:EventTrigger  EventName="Click">
        				<i:InvokeCommandAction Command="{Binding SIMOPSClickCommand}" 
        					CommandParameter="{Binding ElementName=btnSIMOPS}"  />
        			</i:EventTrigger>
        		</i:Interaction.Triggers>
        	</Button>
            <Button x:Name="btnCancelSimops" Command="{Binding CencelSIMOPSEvent}" CommandParameter="{Binding ElementName=btnCancelSimops}" Content="Cencel SIMOPS" IsEnabled="{Binding IsCancelSIMOPSEnabled}" Style="{StaticResource OverlapButtonStyle}" Margin="0,0,0,10" Cursor="Hand" />
            <Button x:Name="btnCrossingLine" IsEnabled="{Binding IsApplyCrossLineEnabled}" Content="Apply Crossing line" Style="{StaticResource OverlapButtonStyle}" Margin="0,0,0,10" Cursor="Hand">
        		<i:Interaction.Triggers>
        			<i:EventTrigger  EventName="Click">
        				<i:InvokeCommandAction Command="{Binding CrossingLineClickCommand}" 
        					CommandParameter="{Binding ElementName=btnCrossingLine}"  />
        			</i:EventTrigger>
        		</i:Interaction.Triggers>
        	</Button>
            <Button x:Name="btnCancelCrossing" Command="{Binding CencelCrossingEvent}" CommandParameter="{Binding ElementName=btnCancelCrossing}" Content="Cancel Crossing line" IsEnabled="{Binding IsCancelCrossLineEnabled}" Margin="0,0,0,10" Style="{StaticResource OverlapButtonStyle}" Cursor="Hand" />
        	<TextBlock Text="Closed strings" Style="{StaticResource ContentHeading}" Margin="0,10,0,2" HorizontalAlignment="Center"/>
            <ComboBox x:Name="cmbClosedStrings" IsEnabled="{Binding IsCombinedTowerEnabled}" ItemsSource="{Binding ClosedStringList}" SelectedItem="{Binding SelectedClosedString, Mode=TwoWay}" VerticalAlignment="Top" Style="{StaticResource ComboBoxStyleNew}" ItemContainerStyle="{StaticResource ComboBoxItemStyle}" Margin="0,0,0,10">
        		<i:Interaction.Triggers>
        			<i:EventTrigger  EventName="SelectionChanged">
        				<i:InvokeCommandAction Command="{Binding ClosedStringSelectionCommand}" 
        					CommandParameter="{Binding ElementName=cmbClosedStrings}"  />
        			</i:EventTrigger>
        		</i:Interaction.Triggers>
        	</ComboBox>
            <Button x:Name="btnReduceCapacity" Content="Reduced Capacity" IsEnabled="{Binding IsEnabledRaducedCapacity}" Command="{Binding ReducedCapacityCommand}" CommandParameter="{Binding ElementName=btnReduceCapacity}" Style="{StaticResource OverlapButtonStyle}" Margin="0,0,0,10" Cursor="Hand" />
            <Button x:Name="btnByPassMOL" Content="Bypass to MOL" IsEnabled="{Binding IsBypassMOLEnabled}" Command="{Binding BypassMOLEvent}" CommandParameter="{Binding ElementName=btnByPassMOL}" Style="{StaticResource OverlapButtonStyle}" Margin="0,0,0,10" Cursor="Hand" Visibility="Collapsed" />
            <Button x:Name="btnRevert" Content="Revert" IsEnabled="{Binding IsLSDRevertEnabled}" Command="{Binding LSDRevertEnabledEvent}" CommandParameter="{Binding ElementName=btnRevert}" Style="{StaticResource OverlapButtonStyle}" Cursor="Hand" />
        </StackPanel>
        <Grid Grid.Column="5" Margin="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <Grid Margin="0,0,0,0" Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="Modifications" HorizontalAlignment="Left" Margin="3,0" Style="{StaticResource ContentHeading}" VerticalAlignment="Bottom"/>
            </Grid>

            <Grid x:Name="thirdGrid" Grid.Row="1" Margin="0,5,0,0">

                <sdk:DataGrid x:Name="linkedShutdownGrid" ItemsSource="{Binding ModifiedLinkedShutdownList}" AutoGenerateColumns="False" 
                          Style="{StaticResource DataGridStyle}" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" IsReadOnly="True" HorizontalAlignment="Stretch">

                    <i:Interaction.Triggers>
                        <i:EventTrigger  EventName="SelectionChanged">
                            <i:InvokeCommandAction Command="{Binding ModifiedActivitySelectChanged}" 
        							CommandParameter="{Binding ElementName=linkedShutdownGrid}"  />
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                    <sdk:DataGrid.Columns>
                        <sdk:DataGridTextColumn Header="Unit Name" Width="*" Binding="{Binding UnitName, Mode=TwoWay}"  />
                        <sdk:DataGridTextColumn Header="Activity" Width="*" Binding="{Binding ActivityCode, Mode=OneWay}" MinWidth="70" />
                        <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=dd/MM/yyyy}"  Width="110"/>
                        <sdk:DataGridTextColumn Header="End Date" Binding="{Binding End,   Mode=OneWay, StringFormat=dd/MM/yyyy}"  Width="110"/>
                        <sdk:DataGridTextColumn Header="Notes" Width="*" Binding="{Binding LsdReason, Mode=OneWay}" MinWidth="144" />
                    </sdk:DataGrid.Columns>

                </sdk:DataGrid>

            </Grid>
        </Grid>





        <Path Data="M25.666672,37 L204.34454,37" Margin="0,10" Grid.Row="1" Grid.ColumnSpan="6" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="False" VerticalAlignment="Top" Height="1" Stroke="{StaticResource LineColor}"/>

        <Grid Margin="0" Grid.Row="2" Grid.ColumnSpan="6">
            <local:UCAppointment_New x:Name="shutdownAppointment" />
        </Grid>


    </Grid>
</UserControl>
